home *** CD-ROM | disk | FTP | other *** search
/ Introduction to 3D Game …ogramming with DirectX 12 / Introduction-to-3D-Game-Programming-with-DirectX-12.ISO / Code.Textures / Chapter 23 Character Animation / SkinnedMesh / ShadowMap.h < prev    next >
C/C++ Source or Header  |  2016-03-02  |  2KB  |  67 lines

  1. //***************************************************************************************
  2. // ShadowMap.h by Frank Luna (C) 2015 All Rights Reserved.
  3. //***************************************************************************************
  4.  
  5. #pragma once
  6.  
  7. #include "../../Common/d3dUtil.h"
  8.  
  9. enum class CubeMapFace : int
  10. {
  11.     PositiveX = 0,
  12.     NegativeX = 1,
  13.     PositiveY = 2,
  14.     NegativeY = 3,
  15.     PositiveZ = 4,
  16.     NegativeZ = 5
  17. };
  18.  
  19. class ShadowMap
  20. {
  21. public:
  22.     ShadowMap(ID3D12Device* device,
  23.         UINT width, UINT height);
  24.         
  25.     ShadowMap(const ShadowMap& rhs)=delete;
  26.     ShadowMap& operator=(const ShadowMap& rhs)=delete;
  27.     ~ShadowMap()=default;
  28.  
  29.     UINT Width()const;
  30.     UINT Height()const;
  31.     ID3D12Resource* Resource();
  32.     CD3DX12_GPU_DESCRIPTOR_HANDLE Srv()const;
  33.     CD3DX12_CPU_DESCRIPTOR_HANDLE Dsv()const;
  34.  
  35.     D3D12_VIEWPORT Viewport()const;
  36.     D3D12_RECT ScissorRect()const;
  37.  
  38.     void BuildDescriptors(
  39.         CD3DX12_CPU_DESCRIPTOR_HANDLE hCpuSrv,
  40.         CD3DX12_GPU_DESCRIPTOR_HANDLE hGpuSrv,
  41.         CD3DX12_CPU_DESCRIPTOR_HANDLE hCpuDsv);
  42.  
  43.     void OnResize(UINT newWidth, UINT newHeight);
  44.  
  45. private:
  46.     void BuildDescriptors();
  47.     void BuildResource();
  48.  
  49. private:
  50.  
  51.     ID3D12Device* md3dDevice = nullptr;
  52.  
  53.     D3D12_VIEWPORT mViewport;
  54.     D3D12_RECT mScissorRect;
  55.  
  56.     UINT mWidth = 0;
  57.     UINT mHeight = 0;
  58.     DXGI_FORMAT mFormat = DXGI_FORMAT_R24G8_TYPELESS;
  59.  
  60.     CD3DX12_CPU_DESCRIPTOR_HANDLE mhCpuSrv;
  61.     CD3DX12_GPU_DESCRIPTOR_HANDLE mhGpuSrv;
  62.     CD3DX12_CPU_DESCRIPTOR_HANDLE mhCpuDsv;
  63.  
  64.     Microsoft::WRL::ComPtr<ID3D12Resource> mShadowMap = nullptr;
  65. };
  66.  
  67.